import 'package:xindong/common/xindong_api_path.dart';
import 'package:xindong/common/xindong_all.dart';
import 'package:xindong/common/xindong_types.dart';
import 'package:xindong/manager/network/xindong_networking.dart';
import 'package:xindong/manager/xindong_user_controller.dart';
import 'package:xindong/models/xindong_word_class.dart';

class XinDongCommonHandle {
  // 常用语
  Future chatCommonWords() async {
    if (!XinDongUserController.to.isUserCompleted) {
      return null;
    }
    final object = await XinDongNetworking.instance.request(
      XinDongApi.chatCommonWords,
      method: XinDongHttpMethod.post,
    );
    if (object.code == XinDongServerStatus.success) {
      List list = object.data;
      XinDongAll.instance.chatCommonWords = list.map((e) => XinDongWordClass.fromJson(e)).toList();
    }
  }

  Future<Map?> requestAuthSlogan({String userId = ""}) async {
    if (!XinDongUserController.to.isUserCompleted) {
      return null;
    }
    final types = XinDongUserController.to.sex == Gender.female ? 2 : 1;
    final object = await XinDongNetworking.instance.request(
      XinDongApi.userAuthSlogan,
      method: XinDongHttpMethod.get,
      parameters: {"types": types, "user_id": userId},
    );
    if (object.code == XinDongServerStatus.success) {
      return object.data;
    }
    return null;
  }
}
